const express = require('express');
const router = express.Router();

//挂载路由

//导入路由处理函数模块
const userHandler = require('../handler/user');

//导入验证数据的中间件
const expressJoi = require('@escook/express-joi');
//导入需要的验证规则对象
const {
  update_user_schema,
  update_password_schema,
  update_avatar_schema,
} = require('../schema/user');

//获取所有用户的路由
// router.get('/users', userHandler.getUsers);

// 获取用户基本信息的路由
router.get('/user', userHandler.getUser);
//更新用户信息的路由
router.post('/user', expressJoi(update_user_schema), userHandler.updateUser);
//更新密码的路由
router.post(
  '/updatepwd',
  expressJoi(update_password_schema),
  userHandler.updatePassword
);
router.get('/acount', userHandler.getUserAcount);

//更换用户头像的路由
// router.post('/update/avatar', expressJoi(update_avatar_schema), userHandler.updateAvatar)

module.exports = router;
